﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using OutLook.Module.Load;
using OutLook.UI.WPFApp.Helpers;
using OutLook.Model.Infrastructure;

namespace OutLook.UI.WPFApp
{
    /// <summary>
    /// Interaction logic for LoginPage.xaml
    /// </summary>
    public partial class LoginPage : Window
    {
        public LoginPage()
        {
            ApplicationCulture.SetCulture();

            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

        }

        private void btn_LogIn_Click(object sender, RoutedEventArgs e)
        {
            Window newW=null;

            if (LoadPackage.Instance.LogIn(txtBx_Login.Text, txtBx_Password.Text))
            {
                if (LoadPackage.Instance.GetCurrentUser().Role == Enumerators.UserRoles.Technolog)
                {
                    newW = new MainWindow();
                }

                if (LoadPackage.Instance.GetCurrentUser().Role == Enumerators.UserRoles.Modeler)
                {
                    newW = new ModelerPage();
                }

                newW.Show();
                this.Close();
            }
            else
            {
                lbl_error.Content = ResourceInformation.LoginPage.LogInError;
            }
        }

        
    }
}
